package com.example.goson;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

import com.google.gson.Gson;

import org.w3c.dom.Text;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initfunction();

    }

    private void initfunction() {
        String str="{\n" +
                "    \"message\": \"success感谢又拍云(upyun.com)提供CDN赞助\",\n" +
                "    \"status\": 200,\n" +
                "    \"date\": \"20200915\",\n" +
                "    \"time\": \"2020-09-15 16:22:59\",\n" +
                "    \"cityInfo\": {\n" +
                "        \"city\": \"珠海市\",\n" +
                "        \"citykey\": \"101280701\",\n" +
                "        \"parent\": \"广东\",\n" +
                "        \"updateTime\": \"13:01\"\n" +
                "    },\n" +
                "    \"data\": {\n" +
                "        \"shidu\": \"89%\",\n" +
                "        \"pm25\": 6.0,\n" +
                "        \"pm10\": 7.0,\n" +
                "        \"quality\": \"优\",\n" +
                "        \"wendu\": \"31\",\n" +
                "        \"ganmao\": \"各类人群可自由活动\",\n" +
                "        \"forecast\": [\n" +
                "            {\n" +
                "                \"date\": \"15\",\n" +
                "                \"high\": \"高温 30℃\",\n" +
                "                \"low\": \"低温 27℃\",\n" +
                "                \"ymd\": \"2020-09-15\",\n" +
                "                \"week\": \"星期二\",\n" +
                "                \"sunrise\": \"06:13\",\n" +
                "                \"sunset\": \"18:29\",\n" +
                "                \"aqi\": 12,\n" +
                "                \"fx\": \"东风\",\n" +
                "                \"fl\": \"4级\",\n" +
                "                \"type\": \"雷阵雨\",\n" +
                "                \"notice\": \"带好雨具，别在树下躲雨\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"date\": \"16\",\n" +
                "                \"high\": \"高温 31℃\",\n" +
                "                \"low\": \"低温 27℃\",\n" +
                "                \"ymd\": \"2020-09-16\",\n" +
                "                \"week\": \"星期三\",\n" +
                "                \"sunrise\": \"06:13\",\n" +
                "                \"sunset\": \"18:28\",\n" +
                "                \"aqi\": 19,\n" +
                "                \"fx\": \"东南风\",\n" +
                "                \"fl\": \"4级\",\n" +
                "                \"type\": \"雷阵雨\",\n" +
                "                \"notice\": \"带好雨具，别在树下躲雨\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"date\": \"17\",\n" +
                "                \"high\": \"高温 31℃\",\n" +
                "                \"low\": \"低温 26℃\",\n" +
                "                \"ymd\": \"2020-09-17\",\n" +
                "                \"week\": \"星期四\",\n" +
                "                \"sunrise\": \"06:13\",\n" +
                "                \"sunset\": \"18:27\",\n" +
                "                \"aqi\": 23,\n" +
                "                \"fx\": \"东风\",\n" +
                "                \"fl\": \"4级\",\n" +
                "                \"type\": \"雷阵雨\",\n" +
                "                \"notice\": \"带好雨具，别在树下躲雨\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"date\": \"18\",\n" +
                "                \"high\": \"高温 30℃\",\n" +
                "                \"low\": \"低温 25℃\",\n" +
                "                \"ymd\": \"2020-09-18\",\n" +
                "                \"week\": \"星期五\",\n" +
                "                \"sunrise\": \"06:13\",\n" +
                "                \"sunset\": \"18:26\",\n" +
                "                \"aqi\": 19,\n" +
                "                \"fx\": \"东风\",\n" +
                "                \"fl\": \"5级\",\n" +
                "                \"type\": \"中雨\",\n" +
                "                \"notice\": \"记得随身携带雨伞哦\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"date\": \"19\",\n" +
                "                \"high\": \"高温 30℃\",\n" +
                "                \"low\": \"低温 25℃\",\n" +
                "                \"ymd\": \"2020-09-19\",\n" +
                "                \"week\": \"星期六\",\n" +
                "                \"sunrise\": \"06:14\",\n" +
                "                \"sunset\": \"18:25\",\n" +
                "                \"aqi\": 16,\n" +
                "                \"fx\": \"东风\",\n" +
                "                \"fl\": \"5级\",\n" +
                "                \"type\": \"中雨\",\n" +
                "                \"notice\": \"记得随身携带雨伞哦\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"date\": \"20\",\n" +
                "                \"high\": \"高温 31℃\",\n" +
                "                \"low\": \"低温 26℃\",\n" +
                "                \"ymd\": \"2020-09-20\",\n" +
                "                \"week\": \"星期日\",\n" +
                "                \"sunrise\": \"06:14\",\n" +
                "                \"sunset\": \"18:24\",\n" +
                "                \"aqi\": 26,\n" +
                "                \"fx\": \"东南风\",\n" +
                "                \"fl\": \"4级\",\n" +
                "                \"type\": \"小雨\",\n" +
                "                \"notice\": \"雨虽小，注意保暖别感冒\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"date\": \"21\",\n" +
                "                \"high\": \"高温 28℃\",\n" +
                "                \"low\": \"低温 24℃\",\n" +
                "                \"ymd\": \"2020-09-21\",\n" +
                "                \"week\": \"星期一\",\n" +
                "                \"sunrise\": \"06:14\",\n" +
                "                \"sunset\": \"18:23\",\n" +
                "                \"aqi\": 22,\n" +
                "                \"fx\": \"南风\",\n" +
                "                \"fl\": \"3级\",\n" +
                "                \"type\": \"小雨\",\n" +
                "                \"notice\": \"雨虽小，注意保暖别感冒\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"date\": \"22\",\n" +
                "                \"high\": \"高温 29℃\",\n" +
                "                \"low\": \"低温 26℃\",\n" +
                "                \"ymd\": \"2020-09-22\",\n" +
                "                \"week\": \"星期二\",\n" +
                "                \"sunrise\": \"06:15\",\n" +
                "                \"sunset\": \"18:22\",\n" +
                "                \"aqi\": 10,\n" +
                "                \"fx\": \"南风\",\n" +
                "                \"fl\": \"3级\",\n" +
                "                \"type\": \"小雨\",\n" +
                "                \"notice\": \"雨虽小，注意保暖别感冒\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"date\": \"23\",\n" +
                "                \"high\": \"高温 28℃\",\n" +
                "                \"low\": \"低温 25℃\",\n" +
                "                \"ymd\": \"2020-09-23\",\n" +
                "                \"week\": \"星期三\",\n" +
                "                \"sunrise\": \"06:15\",\n" +
                "                \"sunset\": \"18:21\",\n" +
                "                \"aqi\": 11,\n" +
                "                \"fx\": \"西北风\",\n" +
                "                \"fl\": \"3级\",\n" +
                "                \"type\": \"中雨\",\n" +
                "                \"notice\": \"记得随身携带雨伞哦\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"date\": \"24\",\n" +
                "                \"high\": \"高温 28℃\",\n" +
                "                \"low\": \"低温 25℃\",\n" +
                "                \"ymd\": \"2020-09-24\",\n" +
                "                \"week\": \"星期四\",\n" +
                "                \"sunrise\": \"06:15\",\n" +
                "                \"sunset\": \"18:20\",\n" +
                "                \"aqi\": 16,\n" +
                "                \"fx\": \"北风\",\n" +
                "                \"fl\": \"4级\",\n" +
                "                \"type\": \"阴\",\n" +
                "                \"notice\": \"不要被阴云遮挡住好心情\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"date\": \"25\",\n" +
                "                \"high\": \"高温 28℃\",\n" +
                "                \"low\": \"低温 25℃\",\n" +
                "                \"ymd\": \"2020-09-25\",\n" +
                "                \"week\": \"星期五\",\n" +
                "                \"sunrise\": \"06:15\",\n" +
                "                \"sunset\": \"18:19\",\n" +
                "                \"aqi\": 22,\n" +
                "                \"fx\": \"东北风\",\n" +
                "                \"fl\": \"3级\",\n" +
                "                \"type\": \"小雨\",\n" +
                "                \"notice\": \"雨虽小，注意保暖别感冒\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"date\": \"26\",\n" +
                "                \"high\": \"高温 28℃\",\n" +
                "                \"low\": \"低温 26℃\",\n" +
                "                \"ymd\": \"2020-09-26\",\n" +
                "                \"week\": \"星期六\",\n" +
                "                \"sunrise\": \"06:16\",\n" +
                "                \"sunset\": \"18:18\",\n" +
                "                \"aqi\": 16,\n" +
                "                \"fx\": \"东北风\",\n" +
                "                \"fl\": \"3级\",\n" +
                "                \"type\": \"中雨\",\n" +
                "                \"notice\": \"记得随身携带雨伞哦\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"date\": \"27\",\n" +
                "                \"high\": \"高温 29℃\",\n" +
                "                \"low\": \"低温 25℃\",\n" +
                "                \"ymd\": \"2020-09-27\",\n" +
                "                \"week\": \"星期日\",\n" +
                "                \"sunrise\": \"06:16\",\n" +
                "                \"sunset\": \"18:17\",\n" +
                "                \"aqi\": 10,\n" +
                "                \"fx\": \"东风\",\n" +
                "                \"fl\": \"4级\",\n" +
                "                \"type\": \"大雨\",\n" +
                "                \"notice\": \"出门最好穿雨衣，勿挡视线\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"date\": \"28\",\n" +
                "                \"high\": \"高温 28℃\",\n" +
                "                \"low\": \"低温 24℃\",\n" +
                "                \"ymd\": \"2020-09-28\",\n" +
                "                \"week\": \"星期一\",\n" +
                "                \"sunrise\": \"06:16\",\n" +
                "                \"sunset\": \"18:16\",\n" +
                "                \"aqi\": 19,\n" +
                "                \"fx\": \"东风\",\n" +
                "                \"fl\": \"3级\",\n" +
                "                \"type\": \"中雨\",\n" +
                "                \"notice\": \"记得随身携带雨伞哦\"\n" +
                "            },\n" +
                "            {\n" +
                "                \"date\": \"29\",\n" +
                "                \"high\": \"高温 26℃\",\n" +
                "                \"low\": \"低温 23℃\",\n" +
                "                \"ymd\": \"2020-09-29\",\n" +
                "                \"week\": \"星期二\",\n" +
                "                \"sunrise\": \"06:17\",\n" +
                "                \"sunset\": \"18:15\",\n" +
                "                \"aqi\": 23,\n" +
                "                \"fx\": \"东风\",\n" +
                "                \"fl\": \"3级\",\n" +
                "                \"type\": \"小雨\",\n" +
                "                \"notice\": \"雨虽小，注意保暖别感冒\"\n" +
                "            }\n" +
                "        ],\n" +
                "        \"yesterday\": {\n" +
                "            \"date\": \"14\",\n" +
                "            \"high\": \"高温 31℃\",\n" +
                "            \"low\": \"低温 26℃\",\n" +
                "            \"ymd\": \"2020-09-14\",\n" +
                "            \"week\": \"星期一\",\n" +
                "            \"sunrise\": \"06:12\",\n" +
                "            \"sunset\": \"18:30\",\n" +
                "            \"aqi\": 15,\n" +
                "            \"fx\": \"东风\",\n" +
                "            \"fl\": \"4级\",\n" +
                "            \"type\": \"中雨\",\n" +
                "            \"notice\": \"记得随身携带雨伞哦\"\n" +
                "        }\n" +
                "    }\n" +
                "}";
        Gson gson=new Gson();
        Text_t text_t = gson.fromJson(str, Text_t.class);

        String city = text_t.getCityInfo().getCity();
        Log.d("xx",city);
        String date = text_t.getData().getYesterday().getDate();
        Log.d("xx",date);
    }
}